﻿//-----------------------------------------------------------------------
// <copyright file="UserInformation.cs" company="HCL">
//     Copyright (c) HCL Technologies.  All rights reserved.
// </copyright>
// <summary>
// Base class for all the user information.
// </summary>
//-----------------------------------------------------------------------
 
namespace HCLT.Practice.WindowsAzure.Solution.STSAuthentication
{
    /// <summary>
    /// generic class for user information
    /// </summary>
    public class UserInformation
    {
        /// <summary>
        /// domain name of the user
        /// </summary>
        private string domainName;

        /// <summary>
        /// domain user name
        /// </summary>
        private string domainUserName;

        /// <summary>
        /// domain active directory
        /// </summary>
        private string domainActiveDirectory;

        /// <summary>
        /// Initializes a new instance of the UserInformation class
        /// </summary>
        public UserInformation()
        {
        }

        /// <summary>
        /// Initializes a new instance of the UserInformation class
        /// </summary>
        /// <param name="userName">name of the logged in user</param>
        public UserInformation(string userName)
        {
            if (userName.IndexOf('\\') > 0)
            {
                this.domainName = userName.Substring(0, userName.IndexOf('\\'));
                this.domainUserName = userName.Substring(userName.IndexOf('\\') + 1, userName.Length - (this.domainName.Length + 1));
            }
            else
            {
                ////get the default domain name 
                this.domainName = ConfigInformation.DefaultDomain;
                this.domainUserName = userName;
            }

            this.domainActiveDirectory = "LDAP://" + this.domainName;
        }

        /// <summary>
        /// Gets the domain user name
        /// </summary>
        public string DomainUserName
        {
            get { return this.domainUserName; }
        }

        /// <summary>
        /// Gets the domain name
        /// </summary>
        public string DomainName
        {
            get { return this.domainName; }
        }

        /// <summary>
        /// Gets the domain active directory
        /// </summary>
        public string DomainActiveDirectory
        {
            get { return this.domainActiveDirectory; }
        }
    }
}